package com.outfoodmanage.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Date;
import java.util.Map;
import java.util.Set;

public class RedisHashUtil {
    
    public static void set(RedisTemplate redisTemplate,String key, Object value){
        String json = JSON.toJSONString(value);
        Map map = JSONObject.parseObject(json, Map.class);
        Set<String> set = map.keySet();
        set.forEach(k -> {
            Object o = map.get(k);
            if(o != null){
                System.out.println(key+"---"+k+"----"+map.get(k));
                redisTemplate.opsForHash().put(key,k,map.get(k));
            }
        }
        );
        redisTemplate.opsForHash().put(key,"updateTime",new Date().getTime());
    }


}
